﻿using CustomAuthorization.MinimumAgeAuthorize;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CustomAuthorization.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    //[Authorize(Policy = "MinimumAge")]
    public class GreetingsController : ControllerBase
    {
        [HttpGet("Hello")]
        [MinimumAgeAuthorize(18)]
        public string Hello()
        {
            return $"Hello {(HttpContext.User.Identity?.Name ?? "Anonymous")}";
        }
    }
}
